package by.bsu.fami.greyscalecodelibrary;

public final class GreysacleCodeLibrary {
	private GreysacleCodeLibrary(){};
	
	public static enum EncodeMode {
		MODE_2_LEVELS,
		MODE_4_LEVELS,
		MODE_8_LEVELS,
		MODE_16_LEVELS
	}
	
	public static final class DecodeResult {
		private String text;
		private byte[] rawBytes;
		private float[] points;
		
		private DecodeResult() {}
		
		public String getText() {
			return text;
		}
		
		public byte[] getRawBytes() {
			return rawBytes;
		}
		
		public float[] getPoints() {
			return points;
		}
	}
	
	public static byte[][] encode(String data, EncodeMode encodeMode) 
				throws WriterException {
		return encode(data, encodeMode.ordinal());
	}
	
	public static byte[][] encode(byte[] data, EncodeMode encodeMode) 
				throws WriterException {
		return encode(data, encodeMode.ordinal());
	}
	
	public native static DecodeResult decode(byte[][] image)
			throws ReaderException, NotFoundException;
	
	private native static byte[][] encode(String data, int encodeMode) 
			throws WriterException;
	
	private native static byte[][] encode(byte[] data, int encodeMode) 
			throws WriterException;
	
	static {
		System.loadLibrary("greyscalecode");
	}
}
